/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package au.edu.swin.unilearn.assignment;

import au.edu.swin.unilearn.subject.Subject;
import au.edu.swin.unilearn.submission.Submission;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.io.*;

/**
 *
 * @author DidierLeung
 */
public class Assignment implements Serializable
{
    private String assignment_no;
    private String assignment_name;
    private String submission_status;
    private Date deadline;
    private double penalty_rate;
    private String source_url;
    private String group_ass;
    private Date active_date;
    private Subject subjectObj;
    private List<Submission> submissionCollection;
    private Date extendedDeadLine;
    private String marking_template_url;

    public Assignment(String assignment_no, String assignment_name,
            String submission_status, Date deadline, double penalty_rate,
            String source_url, String group_ass, Date active_date, Date extendedDeadLine,
            String marking_template_url, Subject subjectObj)
    {
        this.assignment_no = assignment_no;
        this.assignment_name = assignment_name;
        this.submission_status = submission_status;
        this.deadline = deadline;
        this.penalty_rate = penalty_rate;
        this.source_url = source_url;
        this.group_ass = group_ass;
        this.active_date = active_date;
        this.extendedDeadLine = extendedDeadLine;
        this.marking_template_url = marking_template_url;
        this.subjectObj = subjectObj;
        submissionCollection = new ArrayList();
        createSubmissionFolder();
    }

    private void createSubmissionFolder()
    {
        String folderURL = "Unilearn_Storage/" + subjectObj.getSubject_code() + "/Submission";
        File submissionFolder = new File(folderURL);
        File[] tutorialGroupFolders = submissionFolder.listFiles();
        for(File folder : tutorialGroupFolders)
        {
            File assignmentFolder = new File(folderURL + "/" + folder.getName() +"/Assignment_" + assignment_no);
            if(!assignmentFolder.exists())
            {
                assignmentFolder.mkdir();
            }
        }
    }
    
    public String getAssignment_no()
    {
        return assignment_no;
    }

    public void setAssignment_no(String assignment_no)
    {
        this.assignment_no = assignment_no;
    }

    public String getAssignment_name()
    {
        return assignment_name;
    }

    public void setAssignment_name(String assignment_name)
    {
        this.assignment_name = assignment_name;
    }

    public String getSubmission_status()
    {
        return submission_status;
    }

    public void setSubmission_status(String submission_status)
    {
        this.submission_status = submission_status;
    }

    public Date getDeadline()
    {
        return deadline;
    }

    public void setDeadline(Date deadline)
    {
        this.deadline = deadline;
    }

    public double getPenalty_rate()
    {
        return penalty_rate;
    }

    public void setPenalty_rate(double penalty_rate)
    {
        this.penalty_rate = penalty_rate;
    }

    public String getSource_url()
    {
        return source_url;
    }

    public void setSource_url(String source_url)
    {
        this.source_url = source_url;
    }

    public String getGroup_ass()
    {
        return group_ass;
    }

    public void setGroup_ass(String group_ass)
    {
        this.group_ass = group_ass;
    }

    public Date getActive_date()
    {
        return active_date;
    }

    public void setActive_date(Date active_date)
    {
        this.active_date = active_date;
    }

    public Subject getSubjectObj()
    {
        return subjectObj;
    }

    public void setSubjectObj(Subject subjectObj)
    {
        this.subjectObj = subjectObj;
    }

    public List<Submission> getSubmissionCollection()
    {
        return submissionCollection;
    }

    public void setSubmissionCollection(List<Submission> submissionCollection)
    {
        this.submissionCollection = submissionCollection;
    }

    public Date getExtendedDeadLine()
    {
        return extendedDeadLine;
    }

    public void setExtendedDeadLine(Date extendedDeadLine)
    {
        this.extendedDeadLine = extendedDeadLine;
    }

    public String getMarking_template_url()
    {
        return marking_template_url;
    }

    public void setMarking_template_url(String marking_template_url)
    {
        this.marking_template_url = marking_template_url;
    }
}
